package com.yx.enterresourceplanning.controller;

import com.yx.enterresourceplanning.entity.Form;
import com.yx.enterresourceplanning.service.FormService;
import com.yx.enterresourceplanning.utils.ResponseCode;
import com.yx.enterresourceplanning.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/form")
public class FormController {

    @Autowired
    private FormService formService;
    @PostMapping("/FormList")
    public Result<List<Form>> getListFormByFormId(@RequestParam(name = "formId") String formId){
        //根据用户id获取不是待办的验收单方法。
        return Result.success(ResponseCode.SUCCESS, formService.getListFormByFormId(formId));
    }
    @PostMapping("/FormAllList")
    public Result<List<Form>> getListForm(){
        //获取所有验收单方法。
        return Result.success(ResponseCode.SUCCESS, formService.getListForm());
    }
    @PostMapping("/addForm")
    public Result<Integer> addForm(@RequestParam(name = "form_id") String form_id, @RequestParam(name = "form_name")
    String form_name, @RequestParam(name = "form_num") String form_num, @RequestParam(name = "use_dep")
                                   String  use_dep, @RequestParam(name = "work_dep")String work_dep, @RequestParam(name = "oversee_dep")
                                   String  oversee_dep) {
        return Result.success(ResponseCode.SUCCESS, formService.addForm(form_id, form_name, form_num, use_dep, work_dep, oversee_dep));
    }
}
